<!--
 * @Author: wangyu
 * @Date: 2024-12-25 15:04:18
 * @LastEditTime: 2024-12-29 21:56:43
 * @LastEditors: wangyu
 * @Description: 
 * @FilePath: \dzsq-smartpark-platform\index.html
-->
<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <link rel="icon" type="image/svg+xml" href="/vite.svg" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>大足双桥经开区智慧产业园平台</title>
    <style>
      body {
        margin: 0;
      }
      .label-cascader {
        /* background: red!important; */
        /* color: #409eff !important; */
        background-color: #121f3c !important;
        border: 1px solid #1d8fe4 !important;
      }
      .label-cascader .el-cascader-menu__empty-text {
        color: #c9e9f8 !important;
        font-size: 10px !important;
        font-family: Alibaba-PuHuiTi-Regular !important;
      }
      .label-cascader .el-cascader-node__label {
        color: #c9e9f8 !important;
        font-size: 10px !important;
        font-family: Alibaba-PuHuiTi-Regular !important;
      }
      .label-cascader .el-cascader-node__postfix {
        color: #c9e9f8 !important;
      }
      .label-cascader .is-active {
        /* background: red!important; */
        color: #409eff !important;
        /* background-color: rgba(51, 145, 207, 0.1) !important; */
      }
      .label-cascader .el-cascader-node:not(.is-disabled):hover {
        background-color: rgba(51, 145, 207, 0.4) !important;
      }

      .label-cascader .is-active .el-cascader-node__label {
        color: #409eff !important;
      }
      .label-cascader .in-active-path .el-cascader-node__label {
        color: #409eff !important;
      }
      .label-cascader .in-active-path .el-cascader-node__postfix {
        color: #409eff !important;
      }
      .label-cascader .el-cascader-menu:nth-child(1) {
        border-right: 1px solid #1d8fe4 !important;
      }
      .label-cascader .el-cascader-node:focus {
        background-color: rgba(51, 145, 207, 0.4) !important;
      }
    </style>
  </head>
  <body>
    <div id="app"></div>
    <script>
      "object" != typeof ue && (ue = {}),
        (uuidv4 = function () {
          return "10000000-1000-4000-8000-100000000000".replace(
            /[018]/g,
            function (t) {
              return (
                t ^
                (crypto.getRandomValues(new Uint8Array(1))[0] & (15 >> (t / 4)))
              ).toString(16);
            }
          );
        }),
        (ue5 = (function (r) {
          return "object" != typeof ue.interface ||
            "function" != typeof ue.interface.broadcast
            ? ((ue.interface = {}),
              function (t, e, n, o) {
                var u, i;
                "string" == typeof t &&
                  ("function" == typeof e && ((o = n), (n = e), (e = null)),
                  (u = [t, "", r(n, o)]),
                  void 0 !== e && (u[1] = e),
                  (i = encodeURIComponent(JSON.stringify(u))),
                  "object" == typeof history &&
                  "function" == typeof history.pushState
                    ? (history.pushState({}, "", "#" + i),
                      history.pushState({}, "", "#" + encodeURIComponent("[]")))
                    : ((document.location.hash = i),
                      (document.location.hash = encodeURIComponent("[]"))));
              })
            : ((i = ue.interface),
              (ue.interface = {}),
              function (t, e, n, o) {
                var u;
                "string" == typeof t &&
                  ("function" == typeof e && ((o = n), (n = e), (e = null)),
                  (u = r(n, o)),
                  void 0 !== e
                    ? i.broadcast(t, JSON.stringify(e), u)
                    : i.broadcast(t, "", u));
              });
          var i;
        })(function (t, e) {
          if ("function" != typeof t) return "";
          var n = uuidv4();
          return (
            (ue.interface[n] = t),
            setTimeout(function () {
              delete ue.interface[n];
            }, 1e3 * Math.max(1, parseInt(e) || 0)),
            n
          );
        }));
    </script>
    <!-- 事件中心 -->
    <script>
      function eventEmitter() {}
      eventEmitter.prototype.events = {};
      eventEmitter.prototype.on = function (eventName, callback) {
        if (!this.events[eventName]) {
          this.events[eventName] = [];
        }
        this.events[eventName].push(callback);
      };
      eventEmitter.prototype.emit = function (eventName, ...args) {
        if (!this.events[eventName]) {
          return;
        }
        this.events[eventName].map((callback) => callback(...args));
      };
      eventEmitter.prototype.off = function (eventName, callback) {
        const eventCallbacks = this.events[eventName];
        if (!eventCallbacks) return;
        this.events[eventName] = eventCallbacks.filter((cb) => cb !== callback);
      };
      // 创建全局事件中心
      const eventBus = new eventEmitter();
      window.eventBus = eventBus;
    </script>

    <!--前端To UE-->
    <script>
      //前端传数据给UE
      /**
       * @description: 切换下方路由变换三维场景
       */
      eventBus.on("SelectMaInUI", function (data) {
        ue5("SelectMaInUI", data);
      });
      /**
       * @description: 点击门牌切换三维场景
       */
      eventBus.on("SelectBuildingUnit", function (data) {
        ue5("SelectBuildingUnit", data);
      });
      /**
       * @description: 点击楼号切换三维场景
       */
      eventBus.on("SelectBuildingFloor", function (data) {
        console.log(data);
        ue5("SelectBuildingFloor", data);
      });
    </script>

    <!-- UE to前端 -->
    <script>
      /**
       * @description: 选中楼栋获取相关数据
       */
      ue5.interface.ToH5Building = function (data) {
        alert(1);
        eventBus.emit("ToH5Building", data);
      };
      /**
       * @description: 选中楼层获取相关数据
       */
      ue5.interface.ToH5BuildingFloor = function (data) {
        alert(2);
        eventBus.emit("ToH5BuildingFloor", data);
      };
      /**
       * @description: 选中门牌获取相关数据
       */
      ue5.interface.ToH5BuildingFloorUnit = function (data) {
        alert(3);
        eventBus.emit("ToH5BuildingFloorUnit", data);
      };
    </script>
    <script type="module" src="/src/main.js"></script>
  </body>
</html>
